package com.itboye.ihomebank.home;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.base.MyApplcation;
import com.itboye.ihomebank.constants.SPContants;
import com.itboye.ihomebank.me.ActivityFaBuHouse;
import com.itboye.ihomebank.me.ActivityWoDeQiuZu;
import com.itboye.ihomebank.me.WodeFangyuanActivity;
import com.itboye.ihomebank.util.SPUtils;

/**
 * 切换角色
 * 
 */
public class ActivitySwitchRoles extends BaseOtherActivity implements
		OnClickListener {
	private ImageView img_other, close_icon, img_shenfen;// 返回图片
	private TextView add_shap_title_tv;// 标题

	LinearLayout switch_layout01;
	LinearLayout switch_layout02, li_shenfen;
	RelativeLayout jingjiren_renzheng;
	Button renzheng;
	private String brokerValidate;

	@Override
	public void onClick(View v) {
		Intent intent = null;
		switch (v.getId()) {
		case R.id.close_icon:
			this.finish();
			break;
		case R.id.switch_layout01:// 我是房东
			intent = new Intent(MyApplcation.ctx, ActivityFaBuHouse.class);
			startActivity(intent);
			break;
		case R.id.switch_layout02:// 房源管理
			intent = new Intent(this, WodeFangyuanActivity.class);
			startActivity(intent);
			break;
		case R.id.img_other:
			finish();
			break;
		case R.id.renzheng:

		case R.id.img_shenfen:
			intent = new Intent(this, ActivityCardRenZheng.class);
			startActivity(intent);
			// intent = new Intent(this, ActivityRenZheng.class);
			// startActivity(intent);
			break;
		case R.id.li_shenfen:
			// if (brokerValidate != null) {
			// if(brokerValidate.equals("0")){
			intent = new Intent(this, ActivityCardRenZheng.class);
			startActivity(intent);
			// }
			// }
			break;

		default:
			break;
		}

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_switch_roles;
	}

	@Override
	protected void onInitController() {
		// TODO Auto-generated method stub

	}

	@Override
	protected void onInit() {
		// TODO Auto-generated method stub
		add_shap_title_tv.setText("我是房东");
		img_other.setBackgroundResource(R.drawable.qiehuan);
		img_other.setVisibility(View.VISIBLE);
		String identityValidate = SPUtils.get(this, null,
				SPContants.IdentityValidate, "") + "";
		// if (identityValidate != null) {
		// if (identityValidate.equals("0")) {//实名制未认证
		// img_shenfen.setBackgroundResource(R.drawable.chahua);
		// }else if(identityValidate.equals("1")) {//实名制申请中
		// img_shenfen.setBackgroundResource(R.drawable.shenqingzhong);
		// }else if(identityValidate.equals("2")) {//实名制
		// li_shenfen.setVisibility(View.GONE);
		// img_shenfen.setBackgroundResource(R.drawable.chahua);
		// }
		// }
		brokerValidate = SPUtils.get(this, null, SPContants.BrokerValidate, "")
				+ "";
		if (brokerValidate != null) {
			if (brokerValidate.equals("0")) {// 经纪人未认证
				img_shenfen.setBackgroundResource(R.drawable.chahua);
			} else if (brokerValidate.equals("2")) {// 经纪人申请中
				img_shenfen.setBackgroundResource(R.drawable.shenqingzhong);
				renzheng.setVisibility(View.GONE);
			} else if (brokerValidate.equals("1")) {// 经纪人
				li_shenfen.setVisibility(View.GONE);
				img_shenfen.setBackgroundResource(R.drawable.chahua);
			}
		}
	}

	@Override
	protected void onReadIntent(Bundle bundle) {
		// TODO Auto-generated method stub

	}

}
